package com.boot.config;

import com.boot.factory.YamlPropertySourceFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

@Configuration
//@PropertySource() 这个是读取properties文件的 不能读取yml
@PropertySource(
        value = "classpath:db.yml",//指定配置文件
        factory = YamlPropertySourceFactory.class //指定解析工厂
)
public class DBConfig {
    @Value("${mysql.driver}")
    String driver;

    @Value("${mysql.url}")
    String url;

    @Value("${mysql.user}")
    String user;

    @Value("${mysql.pwd}")
    String pwd;

    @Override
    public String toString() {
        return "DBConfig{" +
                "driver='" + driver + '\'' +
                ", url='" + url + '\'' +
                ", user='" + user + '\'' +
                ", pwd='" + pwd + '\'' +
                '}';
    }
}
